﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Meqs.Entity.Views
{
    [Serializable]
    public class Grade
    {
        private int _gradeIndex;
        private string _gradeName;

        public Grade()
        {
        }

        public Grade(int gradeIndex, string gradeName)
        {
            _gradeIndex = gradeIndex;
            _gradeName = gradeName;
        }

        public int GradeIndex
        {
            get { return _gradeIndex; }
            set { _gradeIndex = value; }
        }

        public string GradeName
        {
            get { return _gradeName; }
            set { _gradeName = value; }
        }

        public bool Equals(Grade other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other._gradeIndex == _gradeIndex;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof(Grade)) return false;
            return Equals((Grade)obj);
        }

        public override int GetHashCode()
        {
            return _gradeIndex;
        }

        /// <summary>
        /// 转换年级对象
        /// </summary>
        /// <param name="gradeIndex"></param>
        /// <returns></returns>
        public static Grade ConvertGrade(int gradeIndex)
        {
            if (gradeIndex < 0 || gradeIndex > 12) return null;

            Grade[] grades = new Grade[]
                 {
                     new Grade(1, "一年级"), 
                     new Grade(2, "二年级"), 
                     new Grade(3, "三年级"), 
                     new Grade(4, "四年级"), 
                     new Grade(5, "五年级"), 
                     new Grade(6, "六年级"),
                     new Grade(7, "初一"), 
                     new Grade(8, "初二"), 
                     new Grade(9, "初三"),  
                     new Grade(10, "高一"), 
                     new Grade(11, "高二"), 
                     new Grade(12, "高三") };

            return grades[gradeIndex - 1];
        }
    }
}
